require "import" 
  import "android.widget.*" 
  import "com.androlua.*" 
layout={ 
    GridView, 
    id="grid", 
    numColumns=2, 
    layout_width="fill", 
    layout_height="fill" 
}
items={"Audio ducking on and off", "Separate sound", "DELETE Clipboard history", "Phone info", "TTS volume", "Call number current focus", "Share POST", "Apps", "Get Play store application link", "Clear Telegram storage", "Clear YMusic download", "NewPipe Downloader", "Ymusic Downloader", "Sound and Vibrate On", "Exclusive Language"}
dlg=LuaDialog(this)
dlg.View=loadlayout(layout)
grid.adapter=SingleLineAdapter(service, String(items))
dlg.setTitle ("Exclusive Functions")
dlg.show()
grid.onItemClick=function(l,v)
dlg.dismiss()
task(500, function()
if v.text == "Audio ducking on and off" then if service.click({
{"%TTS settings$500",
"Main TTS engine$500",
"Audio ducking$500",
"%Go back<2$500",
} })
return true end
elseif v.text == "Separate sound" then if service.click({
{"%Notification bar$500",
"Media output$500",
"This phone*>1000$500",
"%go back$500",
}})
return true end
elseif v.text == "DELETE Clipboard history" then if service.click({
{"%Clipboard history$1",
"MANAGE*>1000$1",
"SELECT ALL*>1000$1",
"DELETE*>1000$1",
}})
return true end
elseif v.text == "Phone info" then require 'import'
import "android.content.*"
i= Intent()
.setComponent(ComponentName(
"com.android.phone",
"com.android.phone.settings.RadioInfo"))
this.startActivity(i)
elseif v.text == "TTS volume" then if RFirst then
RFirst = 1;
else
RFirst = 2;
end
if RFirst == 2 then
RCount = 1;
end
if RFirst == 1 then
RCount = RCount+1;
end
if RCount > 2 then
RCount = 1
end
if RCount == 1 then
if service.click({
{"%Jieshuo settings$500",
"General settings*>1000$500",
"TTS volume*>1000*$500",
"<20$500",
"%To end$100",
"50*>1000$50",
"%Go back<2$500",
}
})
return true
end
elseif RCount == 2 then
if service.click({
{"%Jieshuo settings$500",
"General settings*>1000$500",
"TTS volume*>1000$1000",
"<50$500",
"%To top$100",
"20*>1000$50",
"%Go back<2$500",
}
})
return true
end
end
return true
elseif v.text == "Call number current focus" then local telNum= this.getText(node)
local telNum= telNum or ""
local c= {}

for n telNum:gmatch("%d+ %d+ %d+") 
table.insert(c, n)
end

when table.unpack(c) == nil 
for n telNum:gmatch("%d+%d+%d%d+") 
table.insert(c, n)
end

when table.unpack(c) == nil
for n telNum:gmatch("+%d%d%d %d%d %d%d%d %d%d%d")
table.insert(c, n)

end
when table.unpack(c) == nil

this.asyncSpeak("Sorry, this context of numbers is not currently supported.")

if #c != 0
require 'import'
import "android.content.*"
import "android.net.*"
i= Intent(Intent.ACTION_CALL, Uri.parse("tel:"..tostring(c[1])))
this.startActivity(i)
end
elseif v.text == "Share POST" then if service.click({
{"share*>1000$100",
"News Feed*>1000$200",
"POST*>1000$200",
}})
return true end
elseif v.text == "Apps" then require "import"
import "android.content.*"
i= Intent()
.setComponent(ComponentName(
"com.android.settings",
"com.android.settings.applications.ManageApplications"))
this.startActivity(i)
elseif v.text == "Get Play store application link" then name= this.getAppName(node)
local app=node.getPackageName()
url= 'https://play.google.com/store/apps/details?id='..app
service.copy('\n'..name..'\n'..url)
service.postSpeak(300,'application link'..name..' , added to clipboard')
elseif v.text == "Clear Telegram storage" then if service.click({
{">File Manager +",
"Main storage*>1000$500",
"Android*>1000$500",
"data*>1000$500",
"%To end$500",
"org.telegram.messenger*>1000$500",
"<cache*>1000$500",
"%Long press$500",
"Select All*>1000$500",
"Delete*>1000$500",
"OK*>1000$500",
"<View*>1000$500",
"%Go back$500",
"%Go back$500",
"%Go back$500",
"%Go back$500",
"%Go back$500",
"%Go back$500",
}})
return true end
elseif v.text == "Clear YMusic download" then if service.click({
{">YMusic$500",
"Open navigation menu*>1000$500",
"Download manager*>1000$500",
"<Downloads*>1000$500",
"%Next focusable element<2$500",
"%Click$500",
"Delete All*>1000$500",
"Remove from list*>1000$500",
"DELETE*>1000$500",
"<No Downloads*>1000$500",
"%Go back<4$500",
}
})
return true
end

return true
elseif v.text == "NewPipe Downloader" then if service.click({
{"share*>1000$100",
"<Copy link*>1000$200",
"%Previous focusable element$500",
"%Next focusable element$500",
"More*>1000$500",
"NewPipe*>1000$500",
}
})
return true
end

return true
elseif v.text == "Ymusic Downloader" then if service.click({
{"share*>1000$100",
"<Copy link*>1000$200",
"%Previous focusable element$500",
"%Next focusable element$500",
"More*>1000$500",
"YMusic*>1000$500",
"Other Download*>1000$500",
}
})
return true
end

return true
elseif v.text == "Sound and Vibrate On" then require "import";
import "android.content.Context"
import "android.media.AudioManager"
import "com.androlua.*"
local audioManager=service.getSystemService(this.AUDIO_SERVICE)
local audioMode = audioManager.getRingerMode()

if audioMode == 1 then
audioManager.setRingerMode(audioManager.RINGER_MODE_NORMAL)
service.speak ("Sound On")

elseif audioMode == 2 then

audioManager.setRingerMode(audioManager.RINGER_MODE_VIBRATE)


this.speak("Vibrate On")
end
service.postClick(800,{{"%Enable curtain"}})
elseif v.text == "Exclusive Language" then require "import"
   import "android.widget.*"
   import "com.androlua.*"
import "android.net.Uri"
import "android.content.Intent" 
   layout={
     GridView,
     id="grid",
     numColumns=1,
     layout_width="fill",
     layout_height="fill"
   }
 items={"Filipino", "Ilocano", "English"}
   dlg=LuaDialog(this)
   dlg.View=loadlayout(layout)
   grid.adapter=SingleLineAdapter(service, String(items))
dlg.setTitle ("Exclusive Language")
   dlg.show()
   grid.onItemClick=function(l,v)
     dlg.dismiss()
task(500, function()
if v.text == "Filipino" then require 'import'
import "java.util.Locale"
import "android.net.Uri"
url = "https://translate.google.com/m?sl=auto&tl=tl&hl=en"..Locale.getDefault().getLanguage().."&q="..Uri.encode(this.getText(node))
Http.get(url, function(status, result)
if status == 200 then
print(result:match('<div class="result%-container">([^<]+)</div>'))
else
print("Error. :-(")
end
end)
elseif v.text == "Ilocano" then require "import"
import "com.androlua.*"
import "java.util.Locale"
import "android.net.Uri"
url = "https://translate.google.com/m?sl=auto&tl=ilo&hl=en"..Locale.getDefault().getLanguage().."&q="..Uri.encode(this.getText(node))
Http.get(url, function(status, result)
if status == 200 then
print(result:match('<div class="result%-container">([^<]+)</div>'))
else
print("Error. :-(")
end
end)
elseif v.text == "English" then require "import"
import "com.androlua.*"
import "java.util.Locale"
import "android.net.Uri"
url = "https://translate.google.com/m?sl=auto&tl=en&hl=en"..Locale.getDefault().getLanguage().."&q="..Uri.encode(this.getText(node))
Http.get(url, function(status, result)
if status == 200 then
print(result:match('<div class="result%-container">([^<]+)</div>'))
else
print("Error. :-(")
end
end)
end end) end
return true end end) end
return true